package com.hpin.mlxteacher.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hpin.mlxteacher.R;
import com.hpin.mlxteacher.bean.VerResTwo;

import java.util.List;

/**
 * 编辑消息页面 选择收件人的adapter + 宝宝树发帖页面选择标题的adapter
 * Created by Aaron on 2015/7/21.
 */
public class ClassifyAdapter extends BaseAdapter {

    private Context ctx;
    private List<VerResTwo> treeType;

    public ClassifyAdapter(Context ctx, List<VerResTwo> treeType) {
        this.ctx = ctx;
        this.treeType = treeType;
    }

    @Override
    public int getCount() {
        return treeType.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {


        ViewHolder viewHolder=null;

        if (convertView == null) {

            convertView = View.inflate(ctx, R.layout.item_simple, null);
            viewHolder = new ViewHolder();
            viewHolder.tv_classify = (TextView) convertView.findViewById(R.id.tv_classify);
            convertView.setTag(viewHolder);

        }else{
            viewHolder=(ViewHolder) convertView.getTag();
        }

        viewHolder.tv_classify.setText(treeType.get(position).oneName);


        if (treeType.get(position).isSelect == 1) {

            viewHolder.tv_classify.setBackgroundColor(ctx.getResources().getColor(R.color.white));

        }else {
            viewHolder.tv_classify.setBackgroundColor(ctx.getResources().getColor(R.color.gray_bg_eb));
        }
//
//        if (treeType.get(position).isSelect == 1){
//            viewHolder.tv_classify.setBackgroundColor(ctx.getResources().getColor(R.color.gray_bg_eb));
//        }else{
//            viewHolder.tv_classify.setBackgroundColor(ctx.getResources().getColor(R.color.white));
//        }

        return convertView;
    }

    private class ViewHolder {
        private TextView tv_classify;

    }
}
